package com.neutech.shop.mapper.impl;

import com.neutech.shop.entity.ConditionVO;
import com.neutech.shop.entity.Product;
import com.neutech.shop.mapper.ProductMapper;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Neuedu-远哥
 * @version 1.0
 * @date 2021/9/29 9:35
 */
@Repository
public class ProductMapperImpl extends SqlSessionDaoSupport implements ProductMapper {
    @Resource
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }
    @Override
    public List<Product> selectAll() {
        return getSqlSession().getMapper(ProductMapper.class).selectAll();
    }

    @Override
    public void insert(Product product) {
        getSqlSession().getMapper(ProductMapper.class).insert(product);
    }

    @Override
    public List<Product> selectByKeywords(String keywords) {
        return getSqlSession().getMapper(ProductMapper.class).selectByKeywords(keywords);
    }

    @Override
    public List<Product> searchProductComplex(ConditionVO conditionVO) {
        return getSqlSession().getMapper(ProductMapper.class).searchProductComplex(conditionVO);
    }

    @Override
    public List<Product> lastedProduct(int startIndex) {
        return getSqlSession().getMapper(ProductMapper.class).lastedProduct(startIndex);
    }

    @Override
    public Product selectById(Integer id) {
        return getSqlSession().getMapper(ProductMapper.class).selectById(id);
    }
}
